package com.dormitory123.millet.dao.Impl;

import com.dormitory123.millet.dao.BaseDao;
import com.dormitory123.millet.dao.OrderDao;
import com.dormitory123.millet.pojo.Order;

import java.util.List;

/**
 * @author yanhuanzhan
 * @date 2022/1/6 - 19:58
 */
public class OrderDaoImpl extends BaseDao implements OrderDao {
    @Override
    public void createOrder(Order order) {
        String sql = "INSERT INTO t_order(order_id,create_time,price,count,status,user_id) VALUES(?,?,?,?,?,?)";
        update(sql, order.getOrderId(), order.getCreateTime(), order.getPrice(),order.getCount(), order.getStatus(), order.getUserId());
    }

    @Override
    public List<Order> queryOrdersByUserId(Integer userId) {
        String sql = "SELECT `order_id` orderId,`create_time` createTime,`price`,`count`,`status`,`user_id` userId FROM t_order WHERE user_id=?";
        return queryForList(Order.class, sql,userId);
    }
}
